package com.core.base;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 分页查询的结果
 */
public class PageResult<E> {
    public static final int DEFAULT_PAGE_SIZE = 10;
    private int index;
    private int pageSize;
    private long totalCount;
    private List<E> items;

    public PageResult(int index, int pageSize, long totalCount, List<E> items) {
        this.index = index;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.items = items;
    }

    public PageResult() {
        this.index = 0;
        this.pageSize = DEFAULT_PAGE_SIZE;
        this.totalCount = 0;
        this.items = new ArrayList<>();
    }

    public boolean add(E e) {
        return items.add(e);
    }

    public boolean addAll(Collection<? extends E> c) {
        return items.addAll(c);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public List<E> getItems() {
        return items;
    }

    public void setItems(List<E> items) {
        this.items = items;
    }
}
